package com.shrct.businessprocess.product.impl;

import com.shrct.businessprocess.product.RCFullServiceProductEntry;
import com.shrct.businessprocess.product.RCLogicProduct;
import com.shrct.businessprocess.product.RCRegisterProductServiceEvent;
import com.shrct.businessprocess.product.impl.RCFullServiceProductEntryImpl;
import com.shrct.businessprocess.product.impl.RCLogicProductEventImpl;
import com.shrct.businessprocess.product.proxy.RCRegisterProductServiceEventProxy;
import edu.fudan.mylang.pf.IObjectFactory;
import edu.fudan.mylang.utils.DateUtil;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCREGISTERPRODUCTSERVICEEVENT_TYPE")
public class RCRegisterProductServiceEventImpl extends RCLogicProductEventImpl implements RCRegisterProductServiceEvent {
  public RCRegisterProductServiceEventImpl() {
    super();
  }
  
  public RCRegisterProductServiceEventImpl(final RCLogicProduct logicProduct, final RCFullServiceProductEntry fullService) {
    super( logicProduct);
    this.fullService = fullService;
  }
  
  @JoinColumn(name = "fullService_id")
  @ManyToOne(targetEntity = RCFullServiceProductEntryImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCFullServiceProductEntry fullService;
  
  public RCFullServiceProductEntry getFullService() {
    return this.fullService;
  }
  
  public RCRegisterProductServiceEvent setFullService(final RCFullServiceProductEntry fullService) {
    this.fullService = fullService;
    return this;			
    
  }
  
  public String getDescription() {
    Date _end = this.fullService.getEnd();
    String _formatDate = DateUtil.formatDate(_end);
    String _plus = ("\u670D\u52A1\u622A\u6B62\u65E5\u671F\uFF1A" + _formatDate);
    return _plus;
  }
  
  public String getEventTitle() {
    return "\u8BBE\u5B9A\u5382\u5546\u7EF4\u4FDD\u670D\u52A1";
  }
  
  public static RCRegisterProductServiceEvent create(final RCLogicProduct logicProduct, final RCFullServiceProductEntry fullService, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.product.RCRegisterProductServiceEvent rCRegisterProductServiceEvent = new com.shrct.businessprocess.product.impl.RCRegisterProductServiceEventImpl(
    	logicProduct,fullService
    );
    objectFactory.create(rCRegisterProductServiceEvent);
    return rCRegisterProductServiceEvent;			
    
  }
  
  public static RCRegisterProductServiceEvent createRCRegisterProductServiceEventImpl(final RCLogicProduct logicProduct, final RCFullServiceProductEntry fullService, final IObjectFactory objectFactory, final Procedure1<RCRegisterProductServiceEvent> init) {
    com.shrct.businessprocess.product.RCRegisterProductServiceEvent rCRegisterProductServiceEvent = new com.shrct.businessprocess.product.impl.RCRegisterProductServiceEventImpl(
    	logicProduct,fullService
    );
    objectFactory.create(rCRegisterProductServiceEvent);
    init.apply(rCRegisterProductServiceEvent);
    
    return rCRegisterProductServiceEvent;			
    
  }
  
  public RCRegisterProductServiceEventProxy toProxy() {
    com.shrct.businessprocess.product.proxy.RCRegisterProductServiceEventProxy proxy = new com.shrct.businessprocess.product.proxy.RCRegisterProductServiceEventProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
